Color bitmap normalization

ABSTRACT

In remote control systems (as in many other circumstances) the color representation of a bitmap is one of the heaviest factor in term of storage occupation and speed of transmission. Often, only a limited number of colors is actually used by a bitmap, so that the bit pattern of the single pixels is bigger than what is really needed to represent all the possible different colors. With the present invention, in case the number of colors does not exceed a predetermined thresholds, a palette table containing all the colors used in the bitmap is created. The pixel representations in the bitmap are then replaced by a pointer to the corresponding entry in the palette table. This allows to reduce the total size of the bitmap. The reduced bitmap is then transmitted together with the associated palette table. The receiving computer (the controller in a remote control system) is able to rebuild the original bitmap with the help of the palette table.

The present invention relates to a method and system for reducing thestorage occupation of a color bitmap, particularly for use in thosesystem where a bitmap must be stored or transmitted through a network.

Bitmap size is a critical parameter, particularly when the bitmap is tobe stored or transmitted over a network. The storage occupation in thefirst case and the speed of transmission in the latter can be heavilyaffected. For this reason many techniques have been developed forreducing the size of bitmaps and consequently their storage occupationand speed of transmission. One kind of application, even if not the onlyone, where this need is extremely important is “remote control”. Remotecontrol programs are a special category of communication applications;they go beyond just connecting a computer with another computer toactually taking control of it. By connecting through phone lines andmodems or through LAN connections, these programs can put all theresources of one data processing system (e.g. a personal computer or aworkstation), usually called the target, under the complete control ofanother data processing system (e.g. a personal computer or aworkstation, connected with a LAN), usually called the controller. Thecontroller screen duplicates the target one. The keyboard of thecontroller can enter characters directly on the target data processingsystem; the mouse of the controller can move the mouse pointer on thetarget screen. The controller screen constantly receives data from thetarget data processing system screen. Likewise, the keyboard of thecontroller sends data to the target data processing system every time akey is hit. For all practical purposes, the controller user may as wellbe sitting in front of the target data processing system.

This kind of remote control software can be useful in a number ofcircumstances. Just as an example an office personal computer system canbe controlled and operated from home personal computers. If the officePC is left connected (e.g. to a modem), the control can be taken fromthe home PC and all the resources of the target PC can be controlled andused remotely. A more specific use is to dial in (e.g. via modem) to anetwork—connected PC at the office, log in, and run network applicationsor update shared files on the network.

The bottleneck caused by transmission lines can have a significanteffect on the speed of remote control operations. To boost performances,remote control programs try to reduce and minimize the amount of datathat needs to be transmitted over the communication lines (e.g. LAN ortelephone cables). The refresh of the video image on the display screenof the target PC, which should be duplicated on the controller PC,constitutes the main factor in the transmission speed, due to the largequantity of information which has to be transferred. In the past, remotecontrol programs worked by sending and refreshing the entire image ofthe target PC screen to the remote PC every fraction of a second. Theconstant rate at which the screen images were sent to the controller PCwas called the screen refresh rate. The controller PC screen accuratelyreflected the target PC screen as changes at the target PC would beincluded in the next screen refresh. This approach was, of course, notvery satisfactory in terms of speed, because of the enormous amount ofdata to be transmitted at each refresh.

Often, a change of the image is limited to a small section of the screen(e.g. pulling down a menu, highlighting an object) and only the changeddata need to be refreshed. The controller system can use the screen datapreviously received and just refresh the modified part of the screen. Bycutting out redundant screen refresh data, a remote control program canimprove the response time. Cache memories speed the performance of harddrives and memory chips, and can also be useful for remote controlprograms. The idea behind a cache is to keep recently used data in atemporary storage area that is quickly accessible. If the data are soonneeded again, it is much quicker to access them from a fast- accesstemporary storage area than to retrieve from the original source.According to this technique, elements of a recently displayed screen aresaved as a cache in extended memory. The entire age redraws from thecontroller PC screen cache, eliminating the need to transfer largeamounts of information over the modem from the target to the controllerPC. Screen elements that are often redrawn from a screen cache includebitmaps, text and fonts.

In the transmission of a bitmap image, one of the heaviest informationto send is the color of each pixel. In the well known RGB format, thecolor of each pixel is represented by three octets (i.e. three byteshaving 8 bits each), one for the Red, one for the Green and one for theBlue. The maximum possible number of differnt colors is 16,777,216, i.e.2**24. This representation with all the possible colors is called “truecolor”.

In remote control systems (as in many other circumstances) this detailedcolor representation is not always needed and the transmission of allthis information frequently constitutes an unwanted burden. Usually forthe scope of the controller system, a poorer color image would beenough. For this reason, many remote control systems use color reductionalgorithms to reduce the color representation from 24 (or 16) bits to 8bits or even 4 bits. An example of a function implementing thesealgorithms is GetDIBits from Microsoft. A drawback of prior art colorreduction functions is that they require a relatively long computationtime to perform this color reduction, mostly due to the effort ofcreating a reduced image as close as possible to the original one. Inremote control system, where these operations must be performed veryoften at a very high speed rate, the color reduction delay isunacceptable. An alternative reduction mechanism is the one implementedby Tivoli Remote Control by International Business Machines Corp anddescribed in GB Patent Application 9917455.9. This mechanism has theadvantage of a faster processing, balanced by a reduced precision in thecorrespondance between the resulting “reduced” colors and the originalones. This reduced precision is normally acceptable, particularly inremote control systems, and preferrable to a delay in computation. Amethod combining the speed and easiness of processing with the precisionof the results would therefore be highly welcome.

It is an object of the present invention to provide a technique whichovercomes the above drawbacks.

According to the present invention we provide a method for reducing thesize of a bitmap, the bitmap representing a plurality of pixel, eachpixel being represented by a bit pattern, the method including the stepsof:

counting the number n of different bit patterns included in the bitmap;

creating for later reuse a palette table having at least n entries, eachone of the different patterns having at least one corresponding entrycontaining the bit pattern;

replacing in the bitmap the bit patterns with a pointer to thecorresponding entry in the palette table.

Also according to the present invention we provide a computer programincluding program code means for performing the method above when theprogram is run on a computer.

Various embodiments of the invention will now be described in detail byway of examples, with reference to accompanying figures, where:

FIG. 1 shows schematically the network and the personal computers whichmay be utilized to implement the method and system of the presentinvention;

FIG. 2 shows a color palette according to the prior art;

FIG. 3 shows an example of second level color palette system accordingto a preferred embodiment of the present invention;

FIG. 4 shows the method a according to a preferred embodiment of thepresent invention.

FIG. 1 illustrates an example of a typical Local Area Network (LAN)where a remote control system can be implemented. It comprises a LANserver 101 which acts as a communication bridge between two or more dataprocessing systems. In other connection systems the function of theserver would be performed, for example, by a bridge, a modem, a cableor, in general, any device that, interposed between two or more dataprocessing system, makes them connected.

The data processing system 105 is the controller and can alternativelytake the control of one of the other data processing system 103, 107 and109.

Data processing systems 103, 105, 107 and 109 can be personal computersor workstations available on the market. They preferably include adisplay unit and a keyboard, coupled in a manner well known in the art.Additionally, the data processing systems include a processor systemunit which may serve to mount a fixed disk drive and a diskette drive inaddition to the main processor and memory. Further, in order tofacilitate the utilization of a graphical user interface, the dataprocessing systems preferably include a graphic pointing device, such asa mouse, which may be utilized to manipulate the position of a pointerwithin a visual display on the screen.

Those skilled in the art will appreciate that data processing systemsdescribed above may be implemented utilizing any state of the artpersonal computer, such as the Personal Computer manufactured byInternational Business Machines Corporation.

Data processing systems are usually provided with a graphical userinterface (GUI) to allow a user to control the data processing systemand to present the results of user actions on the system display. In agraphical user interface, applications and data are generally presentedas objects depicted on a user interface. A user is then provided with agraphical, intuitive interface to a complex data processing system whichpermits graphic selection of depicted objects and manipulation ofapplications corresponding to those objects.

There are a number of different graphical user interface environmentscommercially available which utilize the arrangement described above.These environments include the System 7 operating system developed byApple Computer, Inc. (System 7 is a trademark of Apple Computer, Inc.),the Windows graphical user interface developed by the MicrosoftCorporation (Windows is a trademark of Microsoft Corporation) and theOS/2 Presentation Manager developed by International Business MachinesCorporation (OS/2 and Presentation Manager are trademarks ofInternational Business Machines Corporation).

The window environment is generally part of the operating systemsoftware that includes a collection of utility programs for controllingthe operation of the computer system 100.

In the example shown in FIG. 1 system 103 is defined as the targetsystem and all the resources of system 103 can be used and activated bythe controller system. For performing such control, system 105 must beable to represent on its display an exact copy of the target display103.

As mentioned above, one of the heaviest information relating to bitmapsis the color of each pixel of the original image. In remote controlsystem, the level of precision requested is not usually very high andsending complete color information would waste transmission time.According to RGB format, the color of each pixel is represented by threeoctects (i.e. three bytes having 8 bits each), one for Red, one for forGreen and one for Blue. A subset of 256 of the possible 16.777.216colors is usually enough for any applications. For remote controlsystem, 16 colors are sometimes an acceptable compromise. These reducedrepresentation make use of a sort of index (palette) which contains allthe possible colors, usually in a “true-color” representation (i.e.three bytes). Another possible representation used in state of the artsystems is the 64 k color bitmap. In a 64 k-color bitmap each pixel isrepresented by two bytes. These two bytes are not in this case an indexin a 64 k long palette, but represent themselves the color. The sixteenbits are divided in three five-bit long groups. One bit is ignored. Eachof these groups identifies the intensity of one of the basic colors:red, green, and blue.

FIG. 2 shows a state of the art color palette which implements a 256color bitmap. Each pixel of the bitmap 201 will be 8 bits long. The8-bit pixel in this case does not represent the color itself, butinstead an entry to table 203 containing the physical colors used by thesystem. This table is called palette . The palette of a 256-color bitmapmust necessarily have 256 entries: one for each color. Each entry ismade up of three values, representing the amount of green, red, andblue, needed to render the desired color. The use of the color paletteis a technique to normalize the bitmap and save a lot of space. In facteach entry is 3-byte long (RGB) against the 1 byte (8 bits) needed foreach pixel. It is through this mechanism of indexing that the size ofthe bitmap is considerably reduced.

However it may happen, and it normally happens, that most of thesecolors are never actually used. The number of colors that a bitmapsupports determines only the number of bits that are used in that bitmapto represent the color, and not necessarily the number of colors thatare really in use. In other words, one thing is the theoretical numberof colors that could be found in the bitmap and another thing is thenumber of colors really used in the bitmap.

In theory a 256 colors bitmap could even have only 1 color if it is anarea that has been painted with a “solid brush”; 2 colors if it is anarea painted with a 2 color brush, or containing some writings. This isa very usual occurrence in a remote control systems, because it is theclassic case of a big portion of a written page (i.e. when a wordprocessor is displayed on the screen). The same concept can be extendedto 4 colors as well as 16. The method and system according to thepresent invention could be used even with bitmaps having a biggernumbers of colors, but the advantages could be reduced or even vanished.

According to the present invention, when one of the above circumstancesarise (i.e. only a limited number of colors are really used within abitmap) the original bitmap can be substituted by a “normalized” versionwhich addresses only the colors actually used. In the example made inFIG. 1 above, only two colors are represented in the bitmap 201: thefirst (00 in hexadecimal representation) and last (FF) of the 256possible colors. This means that 254 entries of table 203 will never beused by this bitmap. Each pixel in the bitmap requires 8 bits forrepresenting the hexadecimal numbers (4 bits per digit) needed toaddress the 256 entries of the table 203. In this case a single bitwould be enough to represent all the possible colors of the bitmap (0and 1). A table (palette) with two entries having three bytes each couldcontain all he colors needed by the bitmap 201. According to a preferredembodiment of the present invention a “second level palette” can beinterposed between the bitmap 201 and the palette 203 as shown asexample in FIG. 3.

In bitmap 301 the pixel values 00 and FF have been substituted by 0 and1, because the bitmap was actually using just two colors (correspondingto the first (00) and last (FF) hexadecimal entries of the color palette203). The original bitmap 201 of FIG. 2 was using 8 bits per pixel,while the same information could be represented with just one bit perpixel. A bit can in fact represent just two values, which are enough inthis case. The problem is how to match the two values of a bit to thetwo real entries in the 256-color palette. The answer is by using the2nd level palette 303. The 2nd level palette is a way of normalizing thebitmap with respect to the number of colors really in use. It is asecond level of indirection to the original color palette. In otherwords, referring to the above example, the bit value of 0 would addressthe first entry of the 2nd level palette, which would address the entrynumber 00 of the original palette. The bit value of 1 would address thesecond entry of the 2nd level palette, which would address the entrynumber of FF of the original palette.

The example above shows how the original bitmap could be theoreticallyreduced to one eighth of the original size with a very simple operationand without loosing the precision of the original representation. Inthis case it is enough to replace all the occurrences of the byte 00with a bit value of 0 and all the occurrences of the byte FF with a bitvalue of 1. The new bitmap is therefore meaningful when coupled with its2nd level palette. It is by the 2nd level palette that it is possible torebuild the original bitmap.

FIG. 4 shows schematically the steps of a method according to apreferred embodiment of the present invention. A “normalization process”is applied to bitmap 401 to produce as output the package 403, which canbe for example transmitted over a network. Package 403 includes anormalized bitmap 405 and the corresponding palette 407 which is neededto “decode” normalized bitmap 405. A “reverse normalization” processwill receive package 403 as input and it will produce bitmap 409 asoutput. Bitmap 409 corresponds to original bitmap 401. In the exampleabove of a remote control system (see FIG. 1) bitmap 401 must betrasmitted over a network (e.g. A LAN) from a target computer (e.g. 103)to a controller computer 105. If the numbers of colors actually used inthe original bitmap is limited (e.g. less than 16) it could beadvantageous to reduce the size of the color bitmap 401 by applying thenormalization process according to the present invention. Thisnormalization process should be performed in the target computer 103 andit produces as output a normalized bitmap 403, and a palette 407. Thenormalized bitmap has a reduced size and it is easier and faster to betransmitted over the LAN to controller computer 105. When the normalizedbitmap 403 is received by the controller computer 105 together with thepalette 407, a reverse normalization process is able to build the bitmap409 which is identical to original bitmap 401.

In the example made before the system uses a 256 color representationand a corresponding palette 203 (see FIG. 2 and 3) is available both intarget computer 103 and in controller computer 105. The pixels of bitmap401 need therefore 8 bits each to be able to address 256 differentcolors. As mentioned before it may often happen that only a limitedsubset of these 256 colors is actually used. In this case it isadvantageous to substitute the original bitmap 401 with a normalizedbitmap 405, which addresses a “second level” palette. This second levelpalette has as many entries as the maximum number of colors which can berepresented in the normalized palette, according to the following tablePalette entries No. of colors Bits per pixel 1 1 0 2 2 1 4 3 or 4 2 16 4< x <= 16 4 256 x > 16 8

It should be noted that, in the first case no bitmap should be reallytransmitted, because only the single color is needed to reproduce thepicture, while in the last (>16 colors used) there would be no advantagewith the method of the present invention.

According to a preferred embodiment of the present invention the secondlevel palette is obtained with the following steps:

-   -   counting the number of colors actually used by the bitmap to be        transmitted;    -   if this number is less than 16, create a second level palette        (having a size according to the table above) for addressing each        one of these colors on the 256-color palette;    -   substituting the original bitmap with a normalized bitmap where        the pixels address the corresponding colors in the second level        palette.

The present invention has been described in details with reference to astarting bitmap having a 256-color representation. Those skilled in theart will appreciate that this is just an example and the same techniquescan be applied to various representations without big differences.Another possibility, in case the original bitmap uses a colorrepresentation with a bigger number of colors, is to perform a colorreduction step before the normalization process of the example above. Inmany cases this wouldn't be an additional burden, because, as mentionedabove, a color reduction technique is often used in state of the artremote control systems. According to a preferred embodiment of thepresent invention, a color reduction technique, as disclosed in GBPatent Application 9917455.9, is used to convert a 64 k-color bitmap (oreven a “true-color” bitmap) to a 256-color bitmap. When this kind ofcolor reduction is performed the whole bitmap is scanned pixel by pixel.A preferred embodiment of the present invention, takes advantage of thisscanning for additional operations:

-   -   to count the number of colors actually in use;    -   to build the second level palette.

The same information can be obviously retrieved without necessarilymodifying the color reduction algorithm, but it is reasonable to do sofor higher efficiency.

The following are examples of the way the method steps described abovecould be implemented in a preferred embodiment of the present invention.

Counting the Number of Colors.

In the case of a 256-color bitmap, it is enough to allocate a 256 bytelong array and a counter. Initialize the array and the counter to zeros.To count the number of colors you need to scan the bitmap. Every timethat a new pixel is scanned, use the pixel as the index to this array.If the corresponding element value is still at 0, change it to 1 andincrement the counter. When the scanning is complete the counterindicates the number of colors really used by the bitmap.

Normalization of the Bitmap.

In the case of a 256-color bitmap, it is enough to allocate a 256 byteindirection array. Again, it is obvious that this scanning, whenpossibly, should take advantage of a scanning of the existing method. Avariable is needed that indicates which new entry in the indirectionindex array is being added. This array represents the translation of thecorresponding palette entry in the 2 nd level palette. Therefore itturns out that only N entries will be used, where N is exactly thenumber of colors. The value that the other entries assume ismeaningless. Those entries will never be accessed since there is nopixel in the original bitmap pointing to those locations. Every time anew color is encountered the pixel value itself is used as the index tothis array (similar process used when counting the colors) and thecorresponding entry is updated with the new value of the pixel in thenormalized bitmap. The counter is then incremented. The same counterused to count the colors can be used if the two processes are combinedtogether. Once this array is made, it is easy to build the second levelpalette and to perform the normalization of the bitmap, replacing allthe occurrences of the original pixel with the corresponding entry ofthe indirection index.

While the indirection index is used in the normalization bitmap process,the second level palette is used to perform the reverse process. Forthis reason, the second level palette must be transmitted together withthe normalized bitmap, so that the original bitmap can be obtained witha reverse process.

The second level palette is an output of the normalization process, andan input to the reversed normalization process.

In a normalized bitmap a pixel is represented with less bits than theoriginal bitmap. The pixel is interpreted as an index to the 2nd levelPalette where the expanded or original value of the pixel in thenon-normalized bitmap is stored.

Reverse normalization process.

This process is supposed to restore the original bitmap from thenormalized bitmap and the 2 nd level Palette. The process is exactly thereverse of the normalization one. Given the number of bits per pixelused by the normalized bitmap, the process is to replace the occurrenceof each value with the corresponding entry of the 2nd level Palette.

It must be noted that the performances of method and system describedabove, when implemented in state of the art systems which store ortransmit color bitmaps (e.g. remote control systems) could be affectedby compression algorithms. It is therefore difficult to give an exactabsolute dimension of the improvement in performances when using thepresent method. It has been estimated anyway that, when a limited numberof colors is used in a bitmap (e.g. less than 16 in a 256 colorrepresentation), an average decrease of 20% in the size of the bitmap isobtained, with consequent reduction in transmission speed rate.

1. A method for reducing the size of a bitmap, the bitmap representing aplurality of pixels, each pixel being represented by a bit pattern, themethod including the steps of: counting the number n of different bitpatterns included in the bitmap; creating for later reuse a palettetable having at least n entries, each one of the different patternshaving at least one corresponding entry containing the bit pattern; andreplacing in the bitmap the bit patterns with a pointer to thecorresponding entry in the palette table.
 2. The method of claim 1wherein each bit pattern represents a color in a three colorrepresentation.
 3. The method of claim 1 wherein the bit patterns arepointers to a second palette table containing indications of colors in athree color representation.
 4. A method for transmitting a bitmap of adigital image over a network, the network connecting a first and asecond computer, the method comprising the steps of: in the firstcomputer, reducing the size of the bitmap by; counting the number n ofdifferent bit patterns included in the bitmap; creating for later reusea palette table having at least n entries, each one of the differentpatterns having at least one corresponding entry containing the bitpattern; replacing in the bitmap the bit patterns with a pointer to thecorresponding entry in the palette table. transmitting the reducedbitmap and the palette table to the second computer; and in the secondcomputer, obtaining the digital image by means of the reduced bitmap andthe palette table.
 5. A computer program product in a computer readablemedium for reducing the sizze of a bitmap, the bitmap representing aplurality of pixels, each pixel being represented by a bit pattern,comprising: means, for reducing the size of the bitmap with the methodof claim 1; means for transmitting the reduced bitmap and the palettetable from the first to the second computer; and means, for obtainingthe digital image using the reduced bitmap and the palette table.
 6. Theproduct of claim 5, wherein the product is used for remotely controllinga computer coupled to a network.
 7. A system for transmitting a bitmapof a digital image over a network, the network connecting a first and asecond computer, the system comprising: means, in the first computer,for reducing the size of the bitmap with the method of claim 1; networkmeans for transmitting the reduced bitmap and the palette table from thefirst to the second computer; and means, in the second computer, forobtaining the digital image using the reduced bitmap and the palettetable.
 8. The system of claim 7, wherein the second computer is used forremotely controlling the first computer over the network.